﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
namespace DemoGame1
{
    public class Food : VisibleGameEntity
    {
        private ContentManager Content;
        public Food(ContentManager content, string strTexturePrefix, int nTextures, Vector2 _topleft, Vector2 _size)
        {
            
            this.Content = content;
            string[] strTexture = new string[nTextures];
            for (int i = 0; i < nTextures; i++)
                strTexture[i] = strTexturePrefix + (i + 1).ToString();
            InitBall(content, strTexture, nTextures, _topleft, _size);
        }
        private void InitBall(ContentManager content, string[] strTexture, int nTextures, Vector2 _topleft, Vector2 _size)
        {
            TopLeft = _topleft;
            Size = _size;
            Texture2D[] textures = new Texture2D[nTextures];
            Sprites = new List<My2DSprite>();
            for (int i = 0; i < nTextures; i++)
                textures[i] = content.Load<Texture2D>(strTexture[i]);
            My2DSprite tempsprite = new My2DSprite(textures, TopLeft);
            Sprites.Add(tempsprite);
            nSprites = 1;
        }
        public override void Draw(SpriteBatch sb, GameTime gameTime)
        {
            if (Visible)
            {
                if (Drawbound)
                {
                    Texture2D texture = Content.Load<Texture2D>("bound");
                    sb.Draw(texture, BoundRect, Color.White);
                }

                base.Draw(sb, gameTime);
            }
        }
        public override void Update(GameTime gameTime)
        {
            if (Visible)
            {
                BoundRect = new Rectangle((int)TopLeft.X, (int)TopLeft.Y, (int)_Size.X, (int)_Size.Y);
                
                base.Update(gameTime);
            }
        }
    }
}
